//
//  GWCategoryViewController.m
//  GiftWanted
//
//  Created by lanou on 15/11/5.
//  Copyright © 2015年 陈文杰. All rights reserved.
//

#import "GWCategoryViewController.h"
#import "GWNavigationController.h"
#import "GWRaidersMainViewController.h"
#import "GWItemsMainViewController.h"

@interface GWCategoryViewController ()

@property (nonatomic, strong) UISegmentedControl *segmentedControl;
@property (nonatomic, strong) GWRaidersMainViewController *raidersMainVC;
@property (nonatomic, strong) GWItemsMainViewController *itemsMainVC;

@end

@implementation GWCategoryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.title = @"分类";
//    self.navigationItem.title = @"分类";
//    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"menu_3"] style:UIBarButtonItemStylePlain target:(GWNavigationController *)self.navigationController action:@selector(showMenu)];
//    self.view.backgroundColor = [UIColor greenColor];
    
    self.navigationController.navigationBar.hidden = YES;
    [self.leftButton setBackgroundImage:[UIImage imageNamed:@"menu_3"] forState:(UIControlStateNormal)];
    [self.leftButton addTarget:(GWNavigationController *)self.navigationController action:@selector(showMenu) forControlEvents:(UIControlEventTouchUpInside)];
    NSArray *arr = @[@"攻略", @"礼物"];
    _segmentedControl = [[UISegmentedControl alloc] initWithItems:arr];
    _segmentedControl.frame = CGRectMake(0, 0, 160, 20);
    _segmentedControl.center = CGPointMake(SCREEN_WIDTH/2, 45);
    _segmentedControl.tintColor = [UIColor whiteColor];
    _segmentedControl.selectedSegmentIndex = 0;
    [_segmentedControl addTarget:self action:@selector(doTapSegmentedControl:) forControlEvents:(UIControlEventValueChanged)];
    [self.topView addSubview:_segmentedControl];
    
    _raidersMainVC = [[GWRaidersMainViewController alloc] init];
    _raidersMainVC.naviC = self.navigationController;
    _raidersMainVC.view.frame = CGRectMake(0, 70, SCREEN_WIDTH, SCREEN_HEIGHT-70);
    
    _itemsMainVC = [[GWItemsMainViewController alloc] init];
    _itemsMainVC.naviC = self.navigationController;
    _itemsMainVC.view.frame = CGRectMake(0, 70, SCREEN_WIDTH, SCREEN_HEIGHT-70);
    
    [self.view addSubview:_itemsMainVC.view];
    [self.view addSubview:_raidersMainVC.view];
}

- (void)doTapSegmentedControl:(UISegmentedControl *)segmentedControl {
    
    switch (segmentedControl.selectedSegmentIndex) {
        case 0:
            [self.view bringSubviewToFront:_raidersMainVC.view];
            break;
        case 1:
            [self.view bringSubviewToFront:_itemsMainVC.view];
            break;
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
